import 'package:flutter/material.dart';
import 'package:flutter_basic_comp/comment/component/tab_custom_view.dart';
import 'comment/component/tab_view.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '方天画戟的Flutter 组件 Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Comp Code 组件 Demo'),
    );
  }
}

// 页面主组件
class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // 定义tab数据
  final List<TabItem> _tabs = [
    TabItem(
      title: '首页',
      content: const TabContentExample(
        title: '首页',
        color: Color(0xFFE3F2FD),
      ),
    ),
    TabItem(
      title: '发现',
      content: const TabContentExample(
        title: '发现',
        color: Color(0xFFF3E5F5),
      ),
    ),
    TabItem(
      title: '消息',
      content: const TabContentExample(
        title: '消息',
        color: Color(0xFFE8F5E8),
      ),
    ),
    TabItem(
      title: '我的',
      content: const TabContentExample(
        title: '我的',
        color: Color(0xFFFFF3E0),
      ),
    ),
  ];
  final List<String> _tabTitles = ['首页', '发现', '消息', '我的'];
  final List<ITabsListItem> _tabsList = [
    ITabsListItem('首页', Icons.home, '首页界面', color: Colors.blue),
    ITabsListItem('发现', Icons.find_replace_sharp, '发现界面', color: Colors.purple),
    ITabsListItem('消息', Icons.message, '消息界面'),
    ITabsListItem('我的', Icons.account_balance, '我的界面欢迎 方天画戟'),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Theme.of(context).colorScheme.inversePrimary,
          title: Text(widget.title),
        ),
        body: Column(
          children: [
            Container(
              padding: const EdgeInsets.all(20),
              child: Column(
                children: [
                  const Text(
                    '点击下面tab进行组件测试',
                    style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                  ),
                ],
              ),
            ),
            // Tab组件区域 Expanded 填充主轴剩余空间
            Expanded(
              child: TabCustomView(
                tabs: _tabsList,
              ),
            ),
          ],
        ));
  }
}
